import { Vec2 } from "cc";


export class TkGameModel  {
    private _inputMoves: Vec2[] = []
    private _frameDatas: proto.MSG_L2B_SubGame100_PlayerInput[] = [];
    frameId: number = 0;

    addInputMoveData(dir: Vec2) {
        this._inputMoves.push(dir)
    }

    getInputMoveData() {
        if (this._inputMoves.length <= 0) return
        const moveData = this._inputMoves.reduce((pre, cur) => {
            return pre.add(cur)
        }, new Vec2())
        this._inputMoves = []
        return moveData
    }

    addFrameData(frameData: proto.MSG_L2B_SubGame100_PlayerInput) {
        this._frameDatas.push(frameData)
    }
    getFrameData() {
        return this._frameDatas.shift()
    }

    getFrameDataCount() {
        return this._frameDatas.length;
    }
}


